import { WIN_MAIN_RENDERER_EVENT_NAME } from '@common/ipcNames';
import { mainHandle } from '@common/mainIpc';
import {
  getVideoInfoList,
  getVideoInfoListCount,
  deleteVideo,
  addVideo,
  getChannelFromDb,
} from '@main/core/sqlite/modules/video_record_and_edit';

export default () => {
  //获取视频列表 -分页
  mainHandle<any>(WIN_MAIN_RENDERER_EVENT_NAME.getVideoInfoQuery, async (data: any) => {
    return await getVideoInfoList(data.params);
  });

  //获取视频列表 -总记录数
  mainHandle<any>(WIN_MAIN_RENDERER_EVENT_NAME.getVideoInfoListCount, async (data: any) => {
    return await getVideoInfoListCount(data.params);
  });

  //删除
  mainHandle<any>(WIN_MAIN_RENDERER_EVENT_NAME.deleteVideo, async (data: any) => {
    return await deleteVideo(data.params);
  });

  //新增
  mainHandle<any>(WIN_MAIN_RENDERER_EVENT_NAME.addVideo, async (data: any) => {
    return await addVideo(data.params);
  });

  //获取数据库中目前通道数据
  mainHandle<any>(WIN_MAIN_RENDERER_EVENT_NAME.getChannelFromDb, async () => {
    return await getChannelFromDb();
  });
};
